import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

//创建一个翻译器
public class UDPDictServer extends UdpEchoServer{
    private HashMap<String,String> dict = null;
    public UDPDictServer(int port) throws SocketException {
        super(port);

        dict = new HashMap<>();
        dict.put("hello","你好");
        dict.put("cat","猫");
        dict.put("dog","狗");
        dict.put("pig","猪");
    }

    //重写 process 方法
    @Override
    public String process(String request){
        return dict.getOrDefault(request,"该词汇没有查询到");
    }

    public static void main(String[] args) throws IOException {
        UDPDictServer udpDictServer = new UDPDictServer(9090);
        udpDictServer.start();
    }

}
